package com.yuexunit.operationman.nbsy.module.nurse.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.nurse.Bean.NurseBean;
import com.yuexunit.operationman.nbsy.module.nurse.ui.Act_Ops_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/7/10 0010.
 */

public class Fragment_intranperative extends KJFragment {
    @Bind(R.id.position)
    TextView position;
    @Bind(R.id.tourniquet)
    TextView tourniquet;
    @Bind(R.id.insert)
    TextView insert;
    @Bind(R.id.operation_sample)
    TextView operationSample;
    @Bind(R.id.drain)
    TextView drain;
    @Bind(R.id.types_anesthesia)
    TextView typesAnesthesia;
    @Bind(R.id.narcotic)
    TextView narcotic;
    @Bind(R.id.dosage)
    TextView dosage;
    @Bind(R.id.anesthesia)
    TextView anesthesia;
    @Bind(R.id.anesthesia_start)
    TextView anesthesiaStart;
    @Bind(R.id.opration_start)
    TextView oprationStart;
    @Bind(R.id.opration_end)
    TextView oprationEnd;
    @Bind(R.id.surgeon)
    TextView surgeon;
    @Bind(R.id.transfuse_drug)
    TextView transfuseDrug;
    @Bind(R.id.flax_meter)
    TextView flaxMeter;
    @Bind(R.id.rate_0)
    TextView rate0;
    @Bind(R.id.bp_0)
    TextView bp0;
    @Bind(R.id.oxygen_0)
    TextView oxygen0;
    @Bind(R.id.rate_1)
    TextView rate1;
    @Bind(R.id.bp_1)
    TextView bp1;
    @Bind(R.id.oxygen_1)
    TextView oxygen1;
    @Bind(R.id.rate_2)
    TextView rate2;
    @Bind(R.id.bp_2)
    TextView bp2;
    @Bind(R.id.oxygen_2)
    TextView oxygen2;
    @Bind(R.id.rate_3)
    TextView rate3;
    @Bind(R.id.bp_3)
    TextView bp3;
    @Bind(R.id.oxygen_3)
    TextView oxygen3;
    @Bind(R.id.rate_4)
    TextView rate4;
    @Bind(R.id.bp_4)
    TextView bp4;
    @Bind(R.id.oxygen_4)
    TextView oxygen4;
    @Bind(R.id.rate_5)
    TextView rate5;
    @Bind(R.id.bp_5)
    TextView bp5;
    @Bind(R.id.oxygen_5)
    TextView oxygen5;
    @Bind(R.id.rate_6)
    TextView rate6;
    @Bind(R.id.bp_6)
    TextView bp6;
    @Bind(R.id.oxygen_6)
    TextView oxygen6;
    @Bind(R.id.rate_7)
    TextView rate7;
    @Bind(R.id.bp_7)
    TextView bp7;
    @Bind(R.id.oxygen_7)
    TextView oxygen7;
    @Bind(R.id.rate_8)
    TextView rate8;
    @Bind(R.id.bp_8)
    TextView bp8;
    @Bind(R.id.oxygen_8)
    TextView oxygen8;
    @Bind(R.id.rate_9)
    TextView rate9;
    @Bind(R.id.bp_9)
    TextView bp9;
    @Bind(R.id.oxygen_9)
    TextView oxygen9;
    @Bind(R.id.rate_10)
    TextView rate10;
    @Bind(R.id.bp_10)
    TextView bp10;
    @Bind(R.id.oxygen_10)
    TextView oxygen10;
    @Bind(R.id.rate_11)
    TextView rate11;
    @Bind(R.id.bp_11)
    TextView bp11;
    @Bind(R.id.oxygen_11)
    TextView oxygen11;
    @Bind(R.id.rate_12)
    TextView rate12;
    @Bind(R.id.bp_12)
    TextView bp12;
    @Bind(R.id.oxygen_12)
    TextView oxygen12;
    @Bind(R.id.rate_end)
    TextView rateEnd;
    @Bind(R.id.bp_end)
    TextView bpEnd;
    @Bind(R.id.oxygen_end)
    TextView oxygenEnd;
    @Bind(R.id.tv_anesthesia)
    LinearLayout tvAnesthesia;
    @Bind(R.id.insert_sign)
    TextView insertSign;
    @Bind(R.id.anesthesia_end)
    TextView anesthesiaEnd;
    @Bind(R.id.tour)
    TextView tour;
    @Bind(R.id.before_condition)
    TextView beforeCondition;
    @Bind(R.id.after_condition)
    TextView afterCondition;
    @Bind(R.id.after_advice)
    TextView afterAdvice;
    @Bind(R.id.rate_13)
    TextView rate13;
    @Bind(R.id.bp_13)
    TextView bp13;
    @Bind(R.id.oxygen_13)
    TextView oxygen13;
    @Bind(R.id.rate_14)
    TextView rate14;
    @Bind(R.id.bp_14)
    TextView bp14;
    @Bind(R.id.oxygen_14)
    TextView oxygen14;
    @Bind(R.id.rate_15)
    TextView rate15;
    @Bind(R.id.bp_15)
    TextView bp15;
    @Bind(R.id.oxygen_15)
    TextView oxygen15;
    @Bind(R.id.SP_Sign)
    TextView SPSign;

    private Act_Ops_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_Ops_Preview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_intranperative, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        for (NurseBean.ObjectEntity.NursingItemListEntity p : AppConfig.NURSEBEAN.getObject().getNursingItemList()) {
            String content = "";
            String[] arrays;
            switch (p.getItemCode()) {
                case "SP_TiWei":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        content = "";
                        arrays = getResources().getStringArray(R.array.nursing_ing_01);
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            content += arrays[1];
                        }
                        if (skin[2].equals("1")) {
                            content += arrays[2];
                        }
                        if (skin[7].equals("1")) {
                            content += arrays[3];
                        }
                        if (skin[8].equals("1")) {
                            content += arrays[4];
                        }
                        if (skin[5].equals("1")) {
                            content += arrays[5];
                            if (skin[4].equals("30")) {
                                content += arrays[8];
                            }
                            if (skin[4].equals("45")) {
                                content += arrays[9];
                            }
                            if (skin[4].equals("90")) {
                                content += arrays[10];
                            }
                        }
                        if (skin[6].equals("1")) {
                            content += arrays[6];
                            if (skin[4].equals("30")) {
                                content += arrays[8];
                            }
                            if (skin[4].equals("45")) {
                                content += arrays[9];
                            }
                            if (skin[4].equals("90")) {
                                content += arrays[10];
                            }
                        }
                        position.setText(content);
                    }

                    if (p.getItemOther().length() > 0) {
                        position.setText("其他:" + p.getItemOther());
                    }
                    break;
                case "SP_ZhiXueDai":
                    content = "";
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            content += "无";
                        }
                        if (skin[1].equals("1")) {
                            content += "压力:" + skin[2] + "\n";
                            if (skin[3].length() > 0) {
                                String[] time = skin[3].split("~", -1);
                                content += "时间1:" + time[0] + "-" + time[1] + "\n";
                            }
                            if (skin[4].length() > 0) {
                                String[] time = skin[3].split("~", -1);
                                content += "时间2:" + time[0] + "-" + time[1] + "\n";
                            }
                        }
                        tourniquet.setText(content);
                    }
                    break;
                case "SP_ZhiRuWu":
                    content = "";
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            content += "无";
                        }
                        if (skin[1].equals("1")) {
                            content += "有";
                            if (p.getItemOther().length() > 0) {
                                content += "\n";
                                String[] medicine = p.getItemOther().split(";", -1);
                                for (int i = 0; i < medicine.length; i++) {
                                    content += medicine[i] + "\n";
                                }

                            }

                        }
                    }
                    insert.setText(content);
                    break;
                case "SP_ZhiRuWuSign":
                    content = "";
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        arrays = getResources().getStringArray(R.array.nursing_ing_05);
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            content += arrays[1];
                        }
                    }
                    insertSign.setText(content);
                    break;
                case "SP_ShouShuBiaoBen_BingDongQiePian":
                    content = "";
                    NurseBean.ObjectEntity.NursingItemListEntity nursingItemListEntity_B = p;
                    if (nursingItemListEntity_B.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[2].equals("1")) {
                            content += "无冰冻切片" + "\n";
                        }
                        if (skin[2].equals("0")) {
                            content += "有冰冻切片" + "\n";
                            content += "名称:" + skin[0] + "\n";
                            content += "数量:" + skin[1] + "\n";
                        }
                    }
                    for (NurseBean.ObjectEntity.NursingItemListEntity p1 : AppConfig.NURSEBEAN.getObject().getNursingItemList()) {
                        switch (p1.getItemCode()) {
                            case "SP_ShouShuBiaoBen_ChangGuiQiePian":
                                if (p1.getItemValue().length() > 0) {
                                    String[] skin = p1.getItemValue().split(";", -1);
                                    if (skin[2].equals("1")) {
                                        content += "无常规切片" + "\n";
                                    }
                                    if (skin[2].equals("0")) {
                                        content += "有常规切片" + "\n";
                                        content += "名称:" + skin[0] + "\n";
                                        content += "数量:" + skin[1] + "\n";
                                    }
                                }
                                break;
                            case "SP_ShouShuBiaoBen_other":
                                if (p1.getItemValue().length() > 0) {
                                    String[] skin = p1.getItemValue().split(";", -1);
                                    if (skin[2].equals("0")) {
                                    }
                                    if (skin[2].equals("1")) {
                                        content += "其他:" + skin[0] + "\n";
                                        content += "数量:" + skin[1] + "\n";
                                    }
                                }
                                break;
                        }
                    }
                    operationSample.setText(content);
                    break;
                case "SP_YinLiuWu":
                    content = "";
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            content += "无" + "\n";
                        }
                        if (skin[1].equals("1")) {
                            content += "有" + "\n";
                            content += "数量:" + skin[2] + "\n";
                            content += "部位:" + skin[3] + "\n";
                        }
                    }
                    drain.setText(content);
                    break;
                case "SP_MaZuiZhongLei":
                    content = "";
                    arrays = getResources().getStringArray(R.array.nursing_ing_04);
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            content += arrays[1];
                        }
                        if (skin[2].equals("1")) {
                            content += arrays[2];
                        }
                        if (skin[3].equals("1")) {
                            content += arrays[3];
//                            tvAnesthesia.setVisibility(View.VISIBLE);
//                            if (AppConfig.NURSEBEAN.getObject().getAnaesthesia().getDrugDesc().length() > 0) {
//                                String[] drugDesc = AppConfig.NURSEBEAN.getObject().getAnaesthesia().getDrugDesc().split(";", -1);
//                                narcotic.setText(drugDesc[0]);
//                                dosage.setText(drugDesc[1]);
//                            }
//                            anesthesia.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getAnesthetist());
//                            anesthesiaStart.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getAnesthesiaStartTime());
//                            anesthesiaEnd.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getAnesthesiaEndTime());
//                            tour.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getCircuitDoctor());
//                            beforeCondition.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getBeforeOperationDesc());
//                            oprationStart.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getOperationStartTime());
//                            oprationEnd.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getOperationEndTime());
//                            afterCondition.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getAfterOperationDesc());
//                            surgeon.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getOperationDoctor());
//                            transfuseDrug.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getDrugDrain());
//                            afterAdvice.setText(AppConfig.NURSEBEAN.getObject().getAnaesthesia().getDoctorAdvice());
//                            for (NurseBean.ObjectEntity.NursingItemListEntity p1 : AppConfig.NURSEBEAN.getObject().getNursingItemList()) {
//                                switch (p1.getItemCode()) {
//                                    case "SP_MZ_HR":
//                                        if (p1.getItemValue().length() > 0) {
//                                            String[] skin1 = p1.getItemValue().split(";", -1);
//                                            rate0.setText(skin1[0]);
//                                            rate1.setText(skin1[1]);
//                                            rate2.setText(skin1[2]);
//                                            rate3.setText(skin1[3]);
//                                            rate4.setText(skin1[4]);
//                                            rate5.setText(skin1[5]);
//                                            rate6.setText(skin1[6]);
//                                            rate7.setText(skin1[7]);
//                                            rate8.setText(skin1[8]);
//                                            rate9.setText(skin1[9]);
//                                            rate10.setText(skin1[10]);
//                                            rate11.setText(skin1[11]);
//                                            rate12.setText(skin1[12]);
//                                            rate13.setText(skin1[13]);
//                                            rate14.setText(skin1[14]);
//                                            rate15.setText(skin1[15]);
//                                            rateEnd.setText(skin1[16]);
//                                        }
//                                        break;
//                                    case "SP_MZ_BP":
//                                        if (p1.getItemValue().length() > 0) {
//                                            String[] skin1 = p1.getItemValue().split(";", -1);
//                                            bp0.setText(skin1[0]);
//                                            bp1.setText(skin1[1]);
//                                            bp2.setText(skin1[2]);
//                                            bp3.setText(skin1[3]);
//                                            bp4.setText(skin1[4]);
//                                            bp5.setText(skin1[5]);
//                                            bp6.setText(skin1[6]);
//                                            bp7.setText(skin1[7]);
//                                            bp8.setText(skin1[8]);
//                                            bp9.setText(skin1[9]);
//                                            bp10.setText(skin1[10]);
//                                            bp11.setText(skin1[11]);
//                                            bp12.setText(skin1[12]);
//                                            bp13.setText(skin1[13]);
//                                            bp14.setText(skin1[14]);
//                                            bp15.setText(skin1[15]);
//                                            bpEnd.setText(skin1[16]);
//                                        }
//                                        break;
//                                    case "SP_MZ_OS":
//                                        if (p1.getItemValue().length() > 0) {
//                                            String[] skin1 = p1.getItemValue().split(";", -1);
//                                            oxygen0.setText(skin1[0]);
//                                            oxygen1.setText(skin1[1]);
//                                            oxygen2.setText(skin1[2]);
//                                            oxygen3.setText(skin1[3]);
//                                            oxygen4.setText(skin1[4]);
//                                            oxygen5.setText(skin1[5]);
//                                            oxygen6.setText(skin1[6]);
//                                            oxygen7.setText(skin1[7]);
//                                            oxygen8.setText(skin1[8]);
//                                            oxygen9.setText(skin1[9]);
//                                            oxygen10.setText(skin1[10]);
//                                            oxygen11.setText(skin1[11]);
//                                            oxygen12.setText(skin1[12]);
//                                            oxygen13.setText(skin1[13]);
//                                            oxygen14.setText(skin1[14]);
//                                            oxygen15.setText(skin1[15]);
//                                            oxygenEnd.setText(skin1[16]);
//                                        }
//                                        break;
//                                }
//                            }
                        }
                    }
                    typesAnesthesia.setText(content);
                    break;
                case "SP_Over_Sign":
                    if (p.getItemName().length() > 0) {
                        SPSign.setText(p.getItemName());
                    }
                    break;

            }
        }
    }

}
